
*******************************************************************************
****						Appendix Table G.15	- REGRESSION OF TOTAL TOLL ****
****		ON TIME DIFFERENTIALS: OTHER CORRIDORS						*******
*******************************************************************************

/* *****************
 THE I-10 EAST 
****************** */

use ".\data\clean\HV_ML_reliab_I10E", clear
keep if fwy==10&dir=="E"
format date %d
sort date hour
tempfile temp1
save `temp1'

use ".\data\clean\I10E_laneuse_dataset_15nov14_wcensus.dta",clear
merge m:1 date hour using `temp1', keep(1 3) nogen 

*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Time in Hours"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
replace reliability_diff=0 if reliability_diff<0.01
keep if reliability_diff~=.
la var reliability_diff "Reliability"

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & hour>4 & hour<9, cluster(rt_id)
est sto a1
sum charged_toll  if e(sample)==1
local toll_10E_A=round(`r(mean)',.01)
local ratio_10E_A=round(_b[_cons]/`r(mean)',.01)
sum  TT_dif_hr if e(sample)==1
local ttdiff_10E_A=round(`r(mean)',.01)
local ttdiffm_10E_A=round(60*`r(mean)',.01)
sum  reliability_diff if e(sample)==1
local reliab_10E_A=round(`r(mean)',.01)
local reliabm_10E_A=round(60*`r(mean)',.01)

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & hour>15 & hour<20, cluster(rt_id)
est sto a2
sum charged_toll  if e(sample)==1
local toll_10E_P=round(`r(mean)',.01)
local ratio_10E_P=round(_b[_cons]/`r(mean)',.01)
sum  TT_dif_hr if e(sample)==1
local ttdiff_10E_P=round(`r(mean)',.01)
local ttdiffm_10E_P=round(60*`r(mean)',.01)
sum  reliability_diff if e(sample)==1
local reliab_10E_P=round(`r(mean)',.01)
local reliabm_10E_P=round(60*`r(mean)',.01)

/* *****************
 THE I-110 NORTH 
****************** */

use ".\data\clean\HV_ML_reliab_I110N", clear
keep if fwy==110&dir=="N"
format date %d
sort date hour
tempfile temp2
save `temp2'

use ".\data\clean\laneuse_dataset_01dec14_I110N.dta",clear
merge m:1 date hour using `temp2', keep(1 3) nogen 

*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
*keep if WTP2>0&WTP2~=.
*keep if WTP2~=.
*keep if WTP2<0
drop if ELspeed==.
drop if TT_dif_hr==.
*drop if weekend==1
drop if holiday==1
la var TT_dif_hr "Time in Hours"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
replace reliability_diff=0 if reliability_diff<0.01
keep if reliability_diff~=.
la var reliability_diff "Reliability"

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & hour>4 & hour<9, cluster(rt_id)
est sto a3
sum charged_toll  if e(sample)==1
local toll_110N_A=round(`r(mean)',.01)
local ratio_110N_A=round(_b[_cons]/`r(mean)',.01)
sum  TT_dif_hr if e(sample)==1
local ttdiff_110N_A=round(`r(mean)',.01)
local ttdiffm_110N_A=round(60*`r(mean)',.01)
sum  reliability_diff if e(sample)==1
local reliab_110N_A=round(`r(mean)',.01)
local reliabm_110N_A=round(60*`r(mean)',.01)

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & hour>15 & hour<20, cluster(rt_id)
est sto a4
sum charged_toll  if e(sample)==1
local toll_110N_P=round(`r(mean)',.01)
local ratio_110N_P=round(_b[_cons]/`r(mean)',.01)
sum  TT_dif_hr if e(sample)==1
local ttdiff_110N_P=round(`r(mean)',.01)
local ttdiffm_110N_P=round(60*`r(mean)',.01)
sum  reliability_diff if e(sample)==1
local reliab_110N_P=round(`r(mean)',.01)
local reliabm_110N_P=round(60*`r(mean)',.01)

/* *****************
 THE I-110 SOUTH 
****************** */

use ".\data\clean\HV_ML_reliab_I110S", clear
keep if fwy==110&dir=="S"
format date %d
sort date hour
tempfile temp3
save `temp3'

use ".\data\clean\laneuse_dataset_2dec14_I110S",clear
drop year mont
merge m:1 date hour using `temp3', keep(1 3) nogen 


*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr

drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Time in Hours"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
replace reliability_diff=0 if reliability_diff<0.01
keep if reliability_diff~=.
la var reliability_diff "Reliability"

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & hour>4 & hour<9, cluster(rt_id)
est sto a5
sum charged_toll  if e(sample)==1
local toll_110S_A=round(`r(mean)',.01)
local ratio_110S_A=round(_b[_cons]/`r(mean)',.01)
sum  TT_dif_hr if e(sample)==1
local ttdiff_110S_A=round(`r(mean)',.01)
local ttdiffm_110S_A=round(60*`r(mean)',.01)
sum  reliability_diff if e(sample)==1
local reliab_110S_A=round(`r(mean)',.01)
local reliabm_110S_A=round(60*`r(mean)',.01)

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & hour>15 & hour<20, cluster(rt_id)
est sto a6
sum charged_toll  if e(sample)==1
local toll_110S_P=round(`r(mean)',.01)
local ratio_110S_P=round(_b[_cons]/`r(mean)',.01)
sum  TT_dif_hr if e(sample)==1
local ttdiff_110S_P=round(`r(mean)',.01)
local ttdiffm_110S_P=round(60*`r(mean)',.01)
sum  reliability_diff if e(sample)==1
local reliab_110S_P=round(`r(mean)',.01)
local reliabm_110S_P=round(60*`r(mean)',.01)

esttab   a1 a2 a3 a4 a5 a6 using ".\results\appendix\tabs\ATG15.csv", replace  ///
	nonumbers nodepvars ///
	cells(b(star fmt(%9.2f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(r2 N,fmt(%9.2f %9.0g ) labels(R-squared N ll aic bic)) ///
		 mtitles("I-10E MP" "I-10E AP" "I-110N MP" "I-110N AP" "I-110S MP" "I-110S AP") ///
		 order(_cons TT_dif_hr reliability_diff)

preserve
insheet using 		 ".\results\appendix\tabs\ATG15.csv", comma clear
export excel ".\results\appendix\AppendixFigsTabs.xlsx" , sheetmodify sheet("Appendix Table G.15")
restore

	
putexcel set ".\results\appendix\AppendixFigsTabs.xlsx", modify sheet("Appendix Table G.15")
putexcel A11=("Average Toll") A12=("Urgency's Share of WTP") A13=("Average Time Savings in Hours") ///
A14=("Average Time Savings in Minutes") A15=("Average Reliability in Hours") A16=("Average Reliability in Minutes")

putexcel B11=(`toll_10E_A') B12=(`ratio_10E_A') B13=(`ttdiff_10E_A') B14=(`ttdiffm_10E_A') ///
	B15=(`reliab_10E_A') B16=(`reliabm_10E_A')
putexcel C11=(`toll_10E_P') C12=(`ratio_10E_P') C13=(`ttdiff_10E_P') C14=(`ttdiffm_10E_P')  ///
	C15=(`reliab_10E_P') C16=(`reliabm_10E_P')
putexcel D11=(`toll_110N_A') D12=(`ratio_110N_A') D13=(`ttdiff_110N_A') D14=(`ttdiffm_110N_A')  ///
	D15=(`reliab_110N_A') D16=(`reliabm_110N_A')
putexcel E11=(`toll_110N_P') E12=(`ratio_110N_P') E13=(`ttdiff_110N_P') E14=(`ttdiffm_110N_P')  ///
	E15=(`reliab_110N_P') E16=(`reliabm_110N_P') 
putexcel F11=(`toll_110S_A') F12=(`ratio_110S_A') F13=(`ttdiff_110S_A') F14=(`ttdiffm_110S_A')  ///
	F15=(`reliab_110S_A') F16=(`reliabm_110S_A')
putexcel G11=(`toll_110S_P') G12=(`ratio_110S_P') G13=(`ttdiff_110S_P') G14=(`ttdiffm_110S_P')  ///
	G15=(`reliab_110S_P') G16=(`reliabm_110S_P')
